package com.msxt.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.msxt.dto.UsersEntity;
import com.msxt.mapper.UsersDao;
import com.msxt.result.Query;
import com.msxt.service.UsersService;
import com.msxt.utils.PageUtils;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 系统用户服务实现类
 */
@Service("usersService")
public class UsersServiceImpl extends ServiceImpl<UsersDao, UsersEntity> implements UsersService {

	@Override
	public PageUtils queryPage(Map<String, Object> params) {
		Page<UsersEntity> page = this.page(
				new Query<UsersEntity>(params).getPage(),
				new QueryWrapper<>()
		);
		return new PageUtils(page);
	}

	@Override
	public List<UsersEntity> listView(QueryWrapper<UsersEntity> wrapper) {
		return baseMapper.listView(wrapper);
	}

	@Override
	public PageUtils queryPage(Map<String, Object> params, QueryWrapper<UsersEntity> wrapper) {
		Page<UsersEntity> page = new Query<UsersEntity>(params).getPage();
		page.setRecords(baseMapper.listView(page, wrapper));
		return new PageUtils(page);
	}
}